package util;

import entity.Address;

import java.sql.ResultSet;
import java.sql.SQLException;

public class AddressUtil {
    private AddressUtil() {
    }

    // 从ResultSet中获取数据构建Address对象
    public static Address rsToAddress(ResultSet rs) throws SQLException {
        Address address = new Address();
        address.setAddId(rs.getInt("add_id"));
        address.setUserId(rs.getInt("user_id"));
        address.setReceiverName(rs.getString("receiver_name"));
        address.setReceiverPhone(rs.getString("receiver_phone"));
        address.setReceiverMobile(rs.getString("receiver_mobile"));
        address.setReceiverState(rs.getString("receiver_state"));
        address.setReceiverCity(rs.getString("receiver_city"));
        address.setReceiverDistrict(rs.getString("receiver_district"));
        address.setReceiverAddress(rs.getString("receiver_address"));
        address.setReceiverZip(rs.getString("receiver_zip"));
        address.setIsDefault(rs.getBoolean("is_default"));
        address.setStatus(rs.getBoolean("status"));
        address.setUpdated(rs.getTimestamp("updated"));
        address.setCreated(rs.getTimestamp("created"));
        return address;
    }
}
